
package JET.SA;

import JET.Centers.ControlCenter;
import JET.Frames.DataModels.DataModelsFactory;
import JET.Scene;
import JET.SceneHelper;
import JET.physics.Wall;
import JET.physics.bodies.SpringBody;
import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author 057Ry
 */
public class SA_Wall {

    private static ControlCenter CC = ControlCenter.getInstance();

    ////////////////////////////////////////////////////////////////////////////
    //                              W A L L                                   //
    ////////////////////////////////////////////////////////////////////////////

    public static void addWallToSpringlBody(Wall wall, SpringBody sb, boolean updateSceneTreeSelection) {
        sb.addWallToBorder(wall);
        if (updateSceneTreeSelection)
            DataModelsFactory.getSceneTreeModel().fireSpringBodyChanged(sb);
    }

    public static void removeWallFromSpringBody(Wall wall, Scene scene, boolean updateSceneTreeSelection) {
//        SpringBody sb = scene.getEngine().getSpringBodyThatOwnWall(wall);
        SpringBody sb = SceneHelper.getSpringBodyThatOwnWall(scene, wall);

        if (sb != null) {
            SA_Selection.removeWallFromSelection(wall, scene, true);
            sb.removeWallFromBorder(wall);
            if (updateSceneTreeSelection)
                DataModelsFactory.getSceneTreeModel().fireSpringBodyChanged(sb);
        }
    }

    public static void removeWallsFromSpringBody(ArrayList<Wall> walls, Scene scene, boolean updateSceneTreeSelection) {
        for(Wall w : walls)
            removeWallFromSpringBody(w, scene, updateSceneTreeSelection);
    }

    public static void addWallListToSpringBody(Collection<Wall> wallList, SpringBody sb, boolean updateSceneTreeSelection) {
        sb.addWallsToBorder(wallList);
        if (updateSceneTreeSelection)
            DataModelsFactory.getSceneTreeModel().fireSpringBodyChanged(sb);
    }
}
